﻿using System.Collections.Generic;
using Microsoft.CodeAnalysis;

namespace Beeflys.Generator
{
    abstract class AType : IType
    {
        public AType(ITypeSymbol typeSymbol, List<string> imports, Reflect reflect)
        {
            this.Name = typeSymbol.Name;
            this.FullName = typeSymbol.ToString();
            if (FullName == Name)
            {
                this.Namespace = string.Empty;
            }
            else
            {
                this.Namespace = FullName.Replace($"{Name}.", "");
            }

            this.Imports = imports;
            this.reflect = reflect;
            this.IsSelfAssembly = reflect.Assembly == typeSymbol.ContainingAssembly;


            this.Parse(typeSymbol);
        }
        
        public string Namespace { get; }
        public string Name { get; }
        public string FullName { get; }
        public List<string> Imports { get; }
        public abstract TypeOptions Options { get; }

        public bool IsSelfAssembly { get; private set; }

        protected readonly Reflect reflect;
        
        protected abstract void Parse(ITypeSymbol symbol);
    }
}